/**
 * ---------------------------
 * Time: 2017/8/14 18:43.
 * Author: Cangshi
 * View: http://palerock.cn
 * ---------------------------
 */
define(['app', 'zepto'], function (app, $) {
    app.controller('running-record', function ($scope, $routeParams) {
        var deviceIndex;
        var init = function () {
            if ($routeParams.deviceIndex == null || Number.isNaN(parseInt($routeParams.deviceIndex))) {
                app.backEvent();
                return;
            }
            deviceIndex = $routeParams.deviceIndex;
            $scope.thisDevice = $scope.devices[deviceIndex];
            if (!$scope.thisDevice) {
                app.backEvent();
            }
        };
        init();
    });
    app.controller('maintain-record', function ($scope, $routeParams) {
        var deviceIndex;
        var maintainPlanIndex;
        var init = function () {
            if ($routeParams.deviceIndex == null || Number.isNaN(parseInt($routeParams.deviceIndex))) {
                app.backEvent();
                return;
            }
            if ($routeParams.maintainPlanIndex == null || Number.isNaN(parseInt($routeParams.maintainPlanIndex))) {
                app.backEvent();
                return;
            }
            deviceIndex = $routeParams.deviceIndex;
            maintainPlanIndex = $routeParams.maintainPlanIndex;
            $scope.thisDevice = $scope.devices[deviceIndex];
            $scope.thisMaintainPlan = $scope.thisDevice.maintainPlans[maintainPlanIndex];
            if (!$scope.thisDevice || !$scope.thisMaintainPlan) {
                app.backEvent();
            }
        };
        init();
    });
});